import { Fragment as _Fragment, createVNode as _createVNode } from "vue";
import PropTypes from '../_util/vue-types';
import initDefaultProps from '../_util/props-util/initDefaultProps';
import CloseCircleFilled from '@ant-design/icons-vue/CloseCircleFilled';
import SearchOutlined from '@ant-design/icons-vue/SearchOutlined';
import Input from '../input';
import { defineComponent } from 'vue';
export var transferSearchProps = {
  prefixCls: PropTypes.string,
  placeholder: PropTypes.string,
  value: PropTypes.string,
  handleClear: PropTypes.func,
  disabled: PropTypes.looseBool,
  onChange: PropTypes.func
};
export default defineComponent({
  name: 'Search',
  inheritAttrs: false,
  props: initDefaultProps(transferSearchProps, {
    placeholder: ''
  }),
  emits: ['change'],
  setup: function setup(props, _ref) {
    var emit = _ref.emit;

    var handleChange = function handleChange(e) {
      emit('change', e);
    };

    var handleClearFn = function handleClearFn(e) {
      var handleClear = props.handleClear,
          disabled = props.disabled;

      if (!disabled && handleClear) {
        handleClear(e);
      }
    };

    return function () {
      var placeholder = props.placeholder,
          value = props.value,
          prefixCls = props.prefixCls,
          disabled = props.disabled;
      var icon = value && value.length > 0 ? _createVNode("a", {
        "class": "".concat(prefixCls, "-action"),
        "onClick": handleClearFn
      }, [_createVNode(CloseCircleFilled, null, null)]) : _createVNode("span", {
        "class": "".concat(prefixCls, "-action")
      }, [_createVNode(SearchOutlined, null, null)]);
      return _createVNode(_Fragment, null, [_createVNode(Input, {
        "placeholder": placeholder,
        "class": prefixCls,
        "value": value,
        "onChange": handleChange,
        "disabled": disabled
      }, null), icon]);
    };
  }
});